// 维修工管理接口文档
import { api } from 'boot/axios'
/** 新增：
 * name	String	是	维修工姓名
 * idNumber	String	是	身份证号码
 * phoneNumber	String	是	联系电话
 * maintenanceProject	String	是	维修项目（如水管维修）
 **/
export interface IRepairWorkerParam {
  name: string
  idNumber: string
  phoneNumber: string
  maintenanceProject: string
}
export type IEditRepairWorkerParam = Partial<IRepairWorkerParam> & {
  maintenanceWorkerId: number
}

const REPAIR_WORKER_URL = '/house/maintenance-worker'
const REPAIR_WORKER_PAGE_URL = '/house/maintenance-worker/page'
const REPAIR_WORKER_LIST_URL = '/house/maintenance-worker/list'

// RepairWorker
export function addRepairWorker(data: IRepairWorkerParam) {
  return api.post(REPAIR_WORKER_URL, data)
}
export function editRepairWorker(data: IEditRepairWorkerParam) {
  return api.put(REPAIR_WORKER_URL, data)
}
export function removeRepairWorker(id: number) {
  return api.delete(`${REPAIR_WORKER_URL}/${id}`)
}
export function getRepairWorkerById(id: number) {
  return api.get(`${REPAIR_WORKER_URL}/${id}`)
}
export function getRepairWorkerList() {
  return api.get(REPAIR_WORKER_LIST_URL)
}
export interface IRepairWorkeryParams {
  pageNum: number
  pageSize: number
  name?: string
}
export function getRepairWorkerPageList(oArg: IRepairWorkeryParams) {
  const params: IRepairWorkeryParams = { pageNum: oArg.pageNum || 1, pageSize: oArg.pageSize || 10 }
  if (oArg.name) {
    params.name = oArg.name
  }
  return api.get(REPAIR_WORKER_PAGE_URL, { params })
}
